﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcs.Web.project
{
    public partial class listsg : Web.Admin.BasePage
    {
        public string dogid = "NO";
        public string Decode(string str)
        {

            if (dogid == "NO")
            {
                if (Request.Cookies["dogid"] != null)
                    dogid = Request.Cookies["dogid"].Value.ToString();
            }
            return DecodeDog(str, dogid);

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
                Page.DataBind();
            }

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }

        public void BindData()
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int projectId = (Convert.ToInt32(Request.Params["id"]));

                Maticsoft.BLL.project bll = new Maticsoft.BLL.project();
                Maticsoft.Model.project model = bll.GetModel(projectId);
                string projectName = model.projectName;
                lbl_projectname.Text = projectName;

                lcs.BLL.out_storage_detail odm = new BLL.out_storage_detail();
                StringBuilder strWhere = new StringBuilder();
                if (txtKeyword.Text.Trim() != "")
                {
                    strWhere.AppendFormat(" material like '%{0}%'", txtKeyword.Text.Trim());
                }
                if (strWhere.ToString() != "")
                    strWhere.Append(string.Format("and use_projectname='{0}'", projectName));
                else
                    strWhere.Append(string.Format(" use_projectname='{0}'", projectName));
                DataSet ds = odm.GetListByVout_storage_detail_materialinfo(strWhere.ToString());

                this.GridView2.DataSource = ds;
                this.GridView2.DataBind();
            }
        }
        protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView2.PageIndex = e.NewPageIndex;
            BindData();
        }
        protected void gridView_OnRowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                //e.Row.Cells[0].Text = "<input id='Checkbox2' type='checkbox' onclick='CheckAll()'/><label></label>";
            }
        }
         protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
            {
                //当鼠标放上去的时候 先保存当前行的背景颜色 并设置新的背景色
                e.Row.Attributes.Add("onmouseover", "onmouseroverop(this)");
                //当鼠标离开的时候 将背景颜色恢复成之前的颜色
                e.Row.Attributes.Add("onmouseout", "onmouseroutop(this)");
                //单击行改变行背景颜色
                e.Row.Attributes.Add("onclick", "ItemOver(this)");
                HyperLink hl = e.Row.FindControl("HyperLink1") as HyperLink;
                if (hl != null)
                {
                    DataRowView drv = (DataRowView)e.Row.DataItem;
                    if (drv.Row["ofile"].ToString()!= "")
                    {
                        hl.Visible=true;
                        hl.NavigateUrl = drv.Row["ofile"].ToString();
                    }
                }
            }
        }        
       }
}